<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>编辑运费模板</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="{__STATIC__}/layuiAdmin/layui/css/layui.css" rel="stylesheet">
    <link href="{__STATIC__}/layuiAdmin/adminui/dist/css/admin.css" rel="stylesheet">
    <link href="{__STATIC__}/layuiAdmin/style/style.css" rel="stylesheet">
    <style>
        html {background: #fff;padding-top: 20px;}
    </style>
</head>
<body>
    <div class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="m_title" lay-verify="required" placeholder="请输入名称" value="{$data.title}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">模板名称，如：默认运费</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 类型：</label>
            <div class="layui-input-inline w180">
                <select name="m_type" lay-filter="m_type">
                    <option value="0" {eq name="$data.type" value="0"}selected{/eq}>按重量</option>
                    <option value="1" {eq name="$data.type" value="1"}selected{/eq}>按体积</option>
                    <option value="2" {eq name="$data.type" value="2"}selected{/eq}>按件数</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 首重：</label>
            <div class="layui-input-inline w180">
                <input type="text" name="m_first_num" lay-verify="number" value="{$data.first_num}" placeholder="请输入首重" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux"><label id="span_first_num">{eq name="$data.type" value="0"}KG{/eq}{eq name="$data.type" value="1"}m³{/eq}{eq name="$data.type" value="2"}件{/eq}</label></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 首重运费：</label>
            <div class="layui-input-inline w180">
                <input type="text" name="m_first_price" lay-verify="number" value="{$data.first_price}" placeholder="请输入首重运费" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">元</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 续重：</label>
            <div class="layui-input-inline w180">
                <input type="text" name="m_second_num" lay-verify="number" value="{$data.second_num}" placeholder="请输入续重" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux"><label id="span_second_num">{eq name="$data.type" value="0"}KG{/eq}{eq name="$data.type" value="1"}m³{/eq}{eq name="$data.type" value="2"}件{/eq}</label></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 续重运费：</label>
            <div class="layui-input-inline w180">
                <input type="text" name="m_second_price" lay-verify="number" value="{$data.second_price}" placeholder="请输入续重运费" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">元</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span>*</span> 排序：</label>
            <div class="layui-input-inline w80">
                <input type="number" name="m_px" lay-verify="number" value="{$data.sequence}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">越大越靠前</div>
        </div>
        <input type="hidden" name="m_id" value="{$data.id}">
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
        </div>
    </div>
</body>
</html>
<script src="{__STATIC__}/layuiAdmin/layui/layui.js"></script>
<script>
    layui.use(function (){
        let $ = layui.$;
        let form = layui.form;

        /* 监听select */
        form.on('select(m_type)',function (data) {
            if(data.value==0){
                $("#span_first_num").html('KG');
                $("#span_second_num").html('KG');
            }
            else if(data.value==1) {
                $("#span_first_num").html('m³');
                $("#span_second_num").html('m³');
            }
            else {
                $("#span_first_num").html('件');
                $("#span_second_num").html('件');
            }
        });
    });
</script>